package tesys.objects;


/**
 * @author Group5 Comp3350
 *
 */
public class Task 
{
	private String tname;
	private String detail;
	private String uid;//creator id
	private String pid;//project id
	private String tid;//task id
	private boolean done;//this task is done or not
	//constructor
	public Task(String tname, String detail, String uID, String taskID, String pid)
	{
		this.tname=tname;
		this.detail=detail;
		this.uid=uID;
		this.tid=taskID;
		this.pid=pid;
		done = false;
	}

	public Task(String tname, String detail, String uID, String taskID, String pid,boolean done)
	{
		this.tname=tname;
		this.detail=detail;
		this.uid=uID;
		this.tid=taskID;
		this.pid=pid;
		this.done = done;
	}
	public Task(String taskID)
	{
		this.tname=null;
		this.detail=null;
		this.uid=null;
		this.tid=taskID;
		this.pid=null;
		done = false;
	}	
	//Accessor
	public String getName(){return tname;}
	public String getDetail(){return detail;}
	public String getUID(){return uid;}
	public String getPID(){return pid;}
	public String getID(){return tid;}
	
	public boolean isDone()
	{
		return done;
	}
	
	//Mutator 
	public void changeState(boolean state)
	{
		done = state;
	}	
	
	//compareTo()
	//to check if 2 objects are same
	public boolean compareTo(Object obj)
	{
		boolean result;
		Task t;
		
		result = false;
		
		if (obj instanceof Task)
		{
			t = (Task) obj;
			if (t.getID().equalsIgnoreCase(tid))
			{
				result = true;
			}
		}
		return result;
	}

	//toString()
	public String toString () 
	{
		return "Task: "+tid+" "+tname+" "+detail;
	}

}
